package com.ecfront.test.dao;

import java.util.Iterator;
import java.util.List;

import com.ecfront.dao.BannerDAO;
import com.ecfront.pojo.Banner;
import com.ecfront.pojo.GoodsSort;

import junit.framework.TestCase;

public class testBanner extends TestCase {
	private static final BannerDAO bannerDao = (BannerDAO)SpringUtilTest.getBean("BannerDAO");
	//保存测试
	public void testSave(){
		Banner banner = new Banner();
		banner.setPlace(2);
		banner.setImgUrl("http://www.ecfront.com/bg.jpg");
		banner.setInkUrl("http://www.ecfront.com");
		banner.setTagName("广告1");
		bannerDao.save(banner);
	}
	//根据ID测试
	public void testFind(){
		Banner banner = bannerDao.findById(1);
		System.out.println(banner.getTagName());
		System.out.println(banner.getImgUrl());
		System.out.println(banner.getInkUrl());
	}
	//FindAll测试
	public void testFindAll(){
		List list = bannerDao.findAll();
		for(Iterator iter = list.iterator();iter.hasNext();){
			Banner banner = (Banner)iter.next();
			System.out.println(banner.getTagName());
			System.out.println(banner.getImgUrl());
			System.out.println(banner.getInkUrl());
			
		}
	}
	//根据广告名测试
	public void testFindByProperty(){
		String paroperty = "tagName";
		String value = "广告1";
		List list = bannerDao.findByProperty(paroperty, value);
		for(Iterator iter = list.iterator();iter.hasNext();){
			Banner banner = (Banner)iter.next();
			System.out.println(banner.getTagName());
			System.out.println(banner.getImgUrl());
			System.out.println(banner.getInkUrl());
		}
	}
}
